<?php

class DynamicLoadMaterialReceiptsAction extends CAction {
	public function run($projectId, $dateMax, $dateMin = null) {
		$projectId = intval($projectId);
		$criteria = new CDbCriteria();
		$criteria->compare('projectId', $projectId);
		$criteria->compare('receiptDate', '<=' . $dateMax);
		if (!empty($dateMin)) {
			$criteria->compare('receiptDate', '>=' . $dateMin);
		}
		$criteria->addInCondition('materialExpenseId', array(
				null
			));
		$criteria->with = array(
			'warehouseManager',
		);
		$criteria->order = 'receiptDate ASC';
		$models = MaterialReceipt::model()->findAll($criteria);
		if (empty($models)) {
			echo '没有找到申购单号：' . $token;
		} else {
			$this->getController()
				->renderPartial('_dynamicLoadList', array(
					'models' => $models
				));
		}
	}
}
